package com.xuxu.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xuxu.common.utils.R;
import com.xuxu.product.dao.OrderDao;
import com.xuxu.product.entity.OrderEntity;
import com.xuxu.product.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @className: OrderServiceImpl
 * @author: Maxuxu
 * @date: 2022/9/2 15:19
 * @description: 订单类的实现类
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    private OrderDao orderDao;
    @Override
    public R getOrderById(Integer id) {
        return R.ok("根据id获取到的信息").put("data",orderDao.selectById(id));
    }

    @Override
    public R getAllOrder() {
        return R.ok("获取所有的订单信息").put("data", orderDao.selectList(new QueryWrapper<>(null)));
    }

    @Override
    public R SelectBypage(Integer currentPage,Integer pageSize) {
        Page<OrderEntity> page = new Page<>(currentPage, pageSize);
        Page<OrderEntity> selectPage = orderDao.selectPage(page, null);
        return R.ok("成功获取到分页数据").put("data",selectPage);
    }
}
